home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / BlogJetSetup.exe / {app} / Firefox / blogjetthis6.xpi / chrome / blogjetthis.jar / content / blogjetthis / blogjetthisOverlay.xul < prev    next >
Extensible Markup Language  |  2006-09-05  |  3KB  |  83 lines

  1. <?xml version="1.0"?>
  2.  
  3.     <overlay id="BlogJetThisOverlay"
  4.              xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  5.  
  6.     <script type="application/x-javascript">
  7.     <![CDATA[
  8.  
  9.     function BlogJetThis()
  10.     {
  11.         try 
  12.         {        
  13.             // assemble exe filepath
  14.             var filepath = getBlogJetRegistryValue();
  15.  
  16.             /* copy the text to the clipboard */
  17.             goDoCommand('cmd_copy'); 
  18.  
  19.             /* init file */
  20.             var vFile = Components.classes["@mozilla.org/file/local;1"].getService(Components.interfaces.nsILocalFile);
  21.             vFile.initWithPath(filepath);
  22.  
  23.             /* init process */
  24.             var vProcess = Components.classes["@mozilla.org/process/util;1"].getService(Components.interfaces.nsIProcess);
  25.             vProcess.init(vFile);
  26.  
  27.             /* Go */ 
  28.             var vURL = gBrowser.currentURI.spec;
  29.             var vTitle = window.content.document.title;
  30.  
  31.             vProcess.run(false, ['-blogthis', vURL, vTitle], 3, {});
  32.         }
  33.         catch (ex) 
  34.         {
  35.             alert("Unable to initialize BlogJet!\n\nException:\n" + ex);
  36.         }
  37.     }
  38.  
  39.     window.addEventListener("load",bugInit,false);
  40.  
  41.     // hides the item when approproiate (use same logic as for Back, Stop etc.)
  42.     // script written by Stephen Clavering, used in his goHome extension
  43.  
  44.     function bugInit() {
  45.         document.getElementById("contentAreaContextMenu").addEventListener("popupshowing",bugHide,false);
  46.     }
  47.  
  48.     function bugHide() {
  49.         var cm = gContextMenu;
  50.         document.getElementById("blogjetthis").hidden = ( cm.onLink || cm.onImage || cm.onTextInput );
  51.     }
  52.  
  53.     function getBlogJetRegistryValue()
  54.     {
  55.         try {
  56.             const HKCU             = 3;
  57.             const ACC_READ = 0x00020000 | 0x00000001 | 0x00000008 | 0x00000010;
  58.             const targetClass         = "@mozilla.org/browser/shell-service;1";
  59.             
  60.             const registryKey         = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\BlogJet.exe";
  61.             // (Default)
  62.             const registryValue        = "";
  63.             
  64.             var reg = Components.classes["@mozilla.org/windows-registry-key;1"].getService(Components.interfaces.nsIWindowsRegKey);
  65.             reg.open(Components.interfaces.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, registryKey, Components.interfaces.nsIWindowsRegKey.ACCESS_READ);
  66.       var result = reg.readStringValue(registryValue);
  67.       reg.close();
  68.       return result;
  69.         } catch (ex) {
  70.             alert("Could not locate registry value!Key/Value:\n\n" + registryKey + 
  71.                 registryValue + "\n\nException:\n" + ex);
  72.         }    
  73.     }
  74.  
  75.     ]]>
  76.     </script>
  77.  
  78.     <popup id="contentAreaContextMenu">
  79.       <menuitem id="blogjetthis" label="BlogJet This!" accesskey="T" insertafter="context-stop" oncommand="BlogJetThis();"/>
  80.     </popup>
  81.  
  82. </overlay>
  83.